const dgraph = require("dgraph-js");
// const grpc = require("@grpc/grpc-js");
// const dgraph = require("dgraph-js");
const grpc = require("grpc");

async function main () {
  const clientStub = new dgraph.DgraphClientStub("http://alphagprc.youling.io", grpc.credentials.createInsecure());
  const dgraphClient = new dgraph.DgraphClient(clientStub);

  const query = `{
   people(func: has(name)) {
    name
    age
  }
}`;
  const response = await dgraphClient.newTxn().query(query);
  console.log("Response: ", JSON.stringify(response.getJson()));

  clientStub.close();
}

main().then().catch((e) => {
  console.log("ERROR: ", e);
});